import * as tslib_1 from "tslib";
import { Component, Injector, ViewChild, HostBinding, ElementRef } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { Form, FrameComponent, FARRIS_DEVKIT_FRAME_PROVIDERS, ViewModel, COMMAND_HANDLERS_TOKEN, FRAME_ID, BindingData, Repository, UIState, EXCEPTION_HANDLER, NAMESPACE } from '@farris/devkit';
import { FARRIS_COMMAND_SERVICE_FRAME_PROVIDERS } from '@farris/command-services';
import { KeybindingService } from '@farris/command-services';
import { ActivatedRoute, Router } from '@angular/router';
import { FrmI18nSettingService } from '@gsp-sys/rtf-common';
import { DomSanitizer } from '@angular/platform-browser';
import { FocusInvalidService } from '@farris/command-services';
import { EditorTypes } from '@farris/ui-datagrid-editors';
import { DatagridComponent, GRID_SETTINGS_HTTP } from '@farris/ui-datagrid';
import { CommonUtils } from '@farris/ui-common';
import { BefLookupRestService, DefaultComboHttpService } from '@farris/bef';
import { ServerSideToken } from '@farris/ui-lookup';
import { ComboServerSideToken } from '@farris/ui-combo-list';
import { WizardService } from '@farris/ui-wizard';
import { LocalizationService } from "@farris/command-services";
import { Newobject2Xgn6ComponentViewmodel } from '../../viewmodels/newobject2xgn6componentviewmodel';
import { ClzxRepository } from '../../models/clzxrepository';
import { LangService } from '../../lang/lang-pipe';
import { Newobject2Xgn6ComponentViewmodelForm } from '../../viewmodels/form/newobject2xgn6componentviewmodelform';
import { Newobject2Xgn6ComponentViewmodelUIState } from '../../viewmodels/uistate/newobject2xgn6componentviewmodeluistate';
import { newobject2xgn6componentviewmodelAddItem1Handler } from '../../viewmodels/handlers/newobject2xgn6componentviewmodeladditem1handler';
import { newobject2xgn6componentviewmodelRemoveItem1Handler } from '../../viewmodels/handlers/newobject2xgn6componentviewmodelremoveitem1handler';
var Newobject2Xgn6Component = /** @class */ (function (_super) {
    tslib_1.__extends(Newobject2Xgn6Component, _super);
    function Newobject2Xgn6Component(wizardSer, keybindingService, langService, route, router, rootElement, localizationService, frmI18nSettingService, focusInvalidService, farrisGridUtils, sanitizer, injector) {
        var _this = _super.call(this, injector) || this;
        _this.wizardSer = wizardSer;
        _this.keybindingService = keybindingService;
        _this.langService = langService;
        _this.route = route;
        _this.router = router;
        _this.rootElement = rootElement;
        _this.localizationService = localizationService;
        _this.frmI18nSettingService = frmI18nSettingService;
        _this.focusInvalidService = focusInvalidService;
        _this.farrisGridUtils = farrisGridUtils;
        _this.sanitizer = sanitizer;
        _this.injector = injector;
        _this.newobject2_xgn6_dataGridColumns = [];
        _this.cls = 'f-struct-is-subgrid ';
        _this.lang = "";
        _this.size = {};
        _this.enabledLanguageList = [];
        _this.tabsToolbarStates = new BehaviorSubject({});
        _this.tabsToolbarVisibleStates = new BehaviorSubject({});
        _this.newobject2_xgn6_dataGridlineNumberTitle = _this.langService.transform("DataGrid/newobject2-xgn6-dataGrid/lineNumberTitle", _this.lang, "");
        _this.lang = localStorage.getItem('languageCode') || "zh-CHS";
        _this.viewModel.verifycationChanged.subscribe(function (verifyInformations) {
            _this.focusInvalidService.focusGridCell(verifyInformations, _this.newobject2_xgn6_dataGridDataGrid);
        });
        if (_this.frmI18nSettingService) {
            var i18nSetting = _this.frmI18nSettingService.getSetting();
            if (i18nSetting && i18nSetting.languages && i18nSetting.languages.length > 0) {
                i18nSetting.languages.forEach(function (item) {
                    _this.enabledLanguageList.push({
                        code: item.code,
                        name: item.name
                    });
                });
            }
            else {
                console.warn("get current enable languages is null. if this occurs,please ensure the form into the framework.");
                _this.enabledLanguageList.push({ "code": "en", "name": "English" });
                _this.enabledLanguageList.push({ "code": "zh-CHS", "name": "中文简体" });
            }
        }
        return _this;
    }
    Newobject2Xgn6Component.prototype.ngOnInit = function () {
        var _this = this;
        if (this.keybindingService) {
            this.viewModel.keybindingMap.forEach(function (keyBinding, method) {
                _this.keybindingService.register(keyBinding, function () {
                    return _this.viewModel[method]();
                });
            });
        }
        this.newobject2_xgn6_dataGridColumns = [
            [
                {
                    id: 'zsbh_a2b6fe39_6e7x',
                    field: 'zsbh',
                    width: 120,
                    title: this.langService.transform("zsbh_a2b6fe39_6e7x", this.lang, "住宿编号"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "zsbh_a2b6fe39_osuz", "title": "住宿编号", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                },
                {
                    id: 'note2_5c227d8f_fb5g',
                    field: 'note2',
                    width: 120,
                    title: this.langService.transform("note2_5c227d8f_fb5g", this.lang, "住宿相关备注"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "note2_5c227d8f_ehb5", "title": "住宿相关备注", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                },
                {
                    id: 'cjr2_cd5dffd9_k5cq',
                    field: 'cjr2',
                    width: 120,
                    title: this.langService.transform("cjr2_cd5dffd9_k5cq", this.lang, "创建人"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "cjr2_cd5dffd9_hxez", "title": "创建人", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                },
                {
                    id: 'cjsj_3685c6c0_geuh',
                    field: 'cjsj',
                    width: 120,
                    title: this.langService.transform("cjsj_3685c6c0_geuh", this.lang, "创建时间"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "cjsj_3685c6c0_esur", "title": "创建时间", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                },
                {
                    id: 'kssj2_fd32f159_d6me',
                    field: 'kssj2',
                    width: 120,
                    title: this.langService.transform("kssj2_fd32f159_d6me", this.lang, "开始日期"),
                    dataType: 'date',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.DATEPICKER,
                        options: { "id": "kssj2_fd32f159_oucw", "title": "开始日期", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.DATEPICKER", "format": "yyyy-MM-dd", "dateRange": false, "showTime": false, "showType": 1, "dateFormat": "yyyy-MM-dd", "returnFormat": "yyyy-MM-dd", "placeholder": "", "showWeekNumbers": false, "dateRangeDatesDelimiter": "~", "editable": true, "linkedLabelEnabled": false, "linkedLabelClick": "", "hourStep": 1, "minuteStep": 1, "secondStep": 1 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: { "type": "datetime", "options": { "format": "yyyy-MM-dd" } }
                },
                {
                    id: 'jsrq2_b23d5af3_v5o6',
                    field: 'jsrq2',
                    width: 120,
                    title: this.langService.transform("jsrq2_b23d5af3_v5o6", this.lang, "结束日期"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "jsrq2_b23d5af3_xyv3", "title": "结束日期", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                },
                {
                    id: 'zsje_4a39e50c_4wua',
                    field: 'zsje',
                    width: 120,
                    title: this.langService.transform("zsje_4a39e50c_4wua", this.lang, "住宿总费用"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "zsje_4a39e50c_wnlx", "title": "住宿总费用", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                },
                {
                    id: 'zsts_3657f4e0_z7yv',
                    field: 'zsts',
                    width: 120,
                    title: this.langService.transform("zsts_3657f4e0_z7yv", this.lang, "住宿天数"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "zsts_3657f4e0_xpvv", "title": "住宿天数", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                },
                {
                    id: 'zsdj_90bd1927_5jjr',
                    field: 'zsdj',
                    width: 120,
                    title: this.langService.transform("zsdj_90bd1927_5jjr", this.lang, "住宿单价"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "zsdj_90bd1927_9spv", "title": "住宿单价", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                },
                {
                    id: 'sfybt2_e60cd55d_i96e',
                    field: 'sfybt2',
                    width: 120,
                    title: this.langService.transform("sfybt2_e60cd55d_i96e", this.lang, "是否有补贴"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "sfybt2_e60cd55d_4aev", "title": "是否有补贴", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                },
                {
                    id: 'btje2_e4cc080f_88if',
                    field: 'btje2',
                    width: 120,
                    title: this.langService.transform("btje2_e4cc080f_88if", this.lang, "补贴金额"),
                    dataType: 'string',
                    align: 'left',
                    halign: 'left',
                    valign: 'middle',
                    isMultilingualField: false,
                    editor: {
                        type: EditorTypes.TEXTBOX,
                        options: { "id": "btje2_e4cc080f_hfwy", "title": "补贴金额", "placeHolder": "", "readonly": false, "localization": null, "localizationType": null, "type": "EditorTypes.TEXTBOX", "isPassword": false, "maxLength": 36 }
                    },
                    sortable: true,
                    footer: {
                        options: {},
                    },
                    groupFooter: {
                        options: {},
                        formatter: { "type": "none" },
                    },
                    readonly: false,
                    visible: true,
                    allowGrouping: true,
                    filter: false,
                    formatter: {}
                }
            ]
        ];
        this.viewModel.newobject2_xgn6_dataGridColumns = this.newobject2_xgn6_dataGridColumns;
        this.viewModel.dataGridColumnsName = "newobject2_xgn6_dataGridColumns";
        this.onFormLoad();
    };
    Newobject2Xgn6Component.prototype.ngAfterViewInit = function () {
    };
    Newobject2Xgn6Component.prototype.ngOnDestroy = function () {
        // 增加表单的自我销毁
        this.context.dispose && this.context.dispose();
        this.context = null;
        this.subscription = null;
        this.declaration = null;
        this.wizardSer = null;
        this.keybindingService = null;
        this.langService = null;
        this.route = null;
        this.router = null;
        this.rootElement = null;
        this.localizationService = null;
        this.frmI18nSettingService = null;
        this.focusInvalidService = null;
        this.farrisGridUtils = null;
        this.sanitizer = null;
        this.injector = null;
        this.enabledLanguageList = [];
    };
    Newobject2Xgn6Component.prototype.handleSizeChange = function (size) {
        this.size = size;
    };
    Newobject2Xgn6Component.prototype.onFormLoad = function () {
    };
    tslib_1.__decorate([
        ViewChild('newobject2_xgn6_dataGridDataGrid'),
        tslib_1.__metadata("design:type", DatagridComponent)
    ], Newobject2Xgn6Component.prototype, "newobject2_xgn6_dataGridDataGrid", void 0);
    tslib_1.__decorate([
        HostBinding('class'),
        tslib_1.__metadata("design:type", Object)
    ], Newobject2Xgn6Component.prototype, "cls", void 0);
    Newobject2Xgn6Component = tslib_1.__decorate([
        Component({
            selector: 'app-newobject2xgn6component',
            templateUrl: './newobject2xgn6component.html',
            styleUrls: ['./newobject2xgn6component.scss'],
            providers: [
                FARRIS_DEVKIT_FRAME_PROVIDERS,
                FARRIS_COMMAND_SERVICE_FRAME_PROVIDERS,
                { provide: FRAME_ID, useValue: 'newobject2-xgn6-component' },
                { provide: BindingData, useClass: BindingData },
                { provide: Repository, useExisting: ClzxRepository },
                LangService,
                { provide: NAMESPACE, useValue: '' },
                { provide: ServerSideToken, useClass: BefLookupRestService },
                { provide: ComboServerSideToken, useClass: DefaultComboHttpService },
                { provide: GRID_SETTINGS_HTTP, useClass: BefLookupRestService },
                { provide: Form, useClass: Newobject2Xgn6ComponentViewmodelForm },
                { provide: UIState, useClass: Newobject2Xgn6ComponentViewmodelUIState },
                { provide: ViewModel, useClass: Newobject2Xgn6ComponentViewmodel },
                { provide: EXCEPTION_HANDLER, useValue: null },
                { provide: COMMAND_HANDLERS_TOKEN, useClass: newobject2xgn6componentviewmodelAddItem1Handler, multi: true },
                { provide: COMMAND_HANDLERS_TOKEN, useClass: newobject2xgn6componentviewmodelRemoveItem1Handler, multi: true },
            ]
        }),
        tslib_1.__metadata("design:paramtypes", [WizardService,
            KeybindingService,
            LangService,
            ActivatedRoute,
            Router,
            ElementRef,
            LocalizationService,
            FrmI18nSettingService,
            FocusInvalidService,
            CommonUtils,
            DomSanitizer,
            Injector])
    ], Newobject2Xgn6Component);
    return Newobject2Xgn6Component;
}(FrameComponent));
export { Newobject2Xgn6Component };
